//
//  LL360CountDownButton.m
//  LLAccountSDK
//
//  Created by xuyf on 14-2-27.
//  Copyright (c) 2014年 LianLian. All rights reserved.
//

#import "LL360CountDownButton.h"
#import "LLSmallUtil.h"

@implementation LL360CountDownButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        _sendTimeLabel = [[UILabel alloc] initWithFrame:frame];
        [self addSubview:_sendTimeLabel];
        self.sendTimeLabel.hidden = YES;
        self.sendTimeLabel.origin = CGPointMake(20, 0);
        self.sendTimeLabel.height = 45;
        
//        _sendTimeInfoLabel = [UILabel viewWithSelector:@"#TX-8,#TX-H"];
//        self.sendTimeInfoLabel.origin = CGPointMake(30, 0);
//        self.sendTimeInfoLabel.height = 45;
//        [_sendTimeInfoLabel setText:@"秒后重发"];
//        [self addSubview:_sendTimeInfoLabel];
//        self.sendTimeInfoLabel.hidden = YES;
        
        [self stop];
        
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

// 重写此函数，实现界面数字更替
- (void)timeLeft:(int)leftTimeInterval
{
    self.sendTimeLabel.hidden = NO;
//    self.sendTimeInfoLabel.hidden = NO;
    
    [self.sendTimeLabel setText:[NSString stringWithFormat:@"剩余%d秒", leftTimeInterval]];
    
    [self setTitle:@"" forState:UIControlStateNormal];
    
    [super timeLeft:leftTimeInterval];
}

// 重写此函数，实现停止时候的界面切换
- (void)timerStoped
{
    self.sendTimeLabel.hidden = YES;
//    self.sendTimeInfoLabel.hidden = YES;
    
//    [self setTitle:@"重发验证码" forState:UIControlStateNormal];
    
    [super timerStoped];
}

@end

@implementation LLSmallCountDownButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.normalColor = [UIColor colorWithHTMLStr:@"2c75c7"];
        [self stop];
    }
    return self;
}

- (void)timerStoped
{
    [super timerStoped];
    
    [self setTitle:@"获取" forState:UIControlStateNormal];
}
@end